package vues;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import vues.*;
import ressources.Props;
import ctrler.CtrlerConnexion;

public class VueConnexion extends Vue {
	
	private static final long serialVersionUID = -4190156733658368579L;
	
	private JButton btnConnecter, btnAnnuler, btnInscrire;
	private JTextField jtLogin, jtMdp;
	private JLabel lLogin, lMdp, lLang;
	private JComboBox listeLang;
	
	public VueConnexion(){
		super();
		build();
	}
	
	private void build(){
		setTitle(Props.getI18n().getParameter("connection.title"));
		setSize(400,300);
		setLocationRelativeTo(null);
		setResizable(false);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setContentPane(buildContentPane());

	}
	
	private JPanel buildContentPane(){
		JPanel pan = new JPanel();
		pan.setLayout(new GridBagLayout());
		GridBagConstraints c = new GridBagConstraints();
		
		lLang = new JLabel(Props.getI18n().getParameter("connection.lang"));
		c.fill = GridBagConstraints.HORIZONTAL;
		c.gridy = 0;
		c.gridx = 0;
		c.insets = new Insets(10,0,0,0);
		pan.add(lLang,c);

		String[] ExempelLang={"Lang1","Lang2"};//Tableau de langue pour test
		listeLang = new JComboBox(ExempelLang);
        c.fill = GridBagConstraints.HORIZONTAL;
		c.gridy = 0;
		c.gridx = 1;
		c.insets = new Insets(10,0,0,0);
		pan.add(listeLang,c);
		
		lLogin = new JLabel(Props.getI18n().getParameter("connection.login"));
		c.fill = GridBagConstraints.HORIZONTAL;
		c.gridy = 1;
		c.gridx = 0;
		c.insets = new Insets(10,0,0,0);
		pan.add(lLogin, c);
		
		jtLogin = new JTextField();
		jtLogin.setColumns(10);
		c.fill = GridBagConstraints.HORIZONTAL;
		c.gridy = 1;
		c.gridx = 1;
		c.insets = new Insets(10,0,0,0);
		pan.add(jtLogin, c);
		
		lMdp = new JLabel(Props.getI18n().getParameter("connection.mdp"));
		c.fill = GridBagConstraints.HORIZONTAL;
		c.gridy = 2;
		c.gridx = 0;
		c.insets = new Insets(10,0,0,0);
		pan.add(lMdp, c);
		
		jtMdp = new JTextField();
		jtMdp.setColumns(10);
		c.fill = GridBagConstraints.HORIZONTAL;
		c.gridy = 2;
		c.gridx = 1;
		c.insets = new Insets(10,0,0,0);
		pan.add(jtMdp, c);
		
		btnConnecter = new JButton(new CtrlerConnexion(this,Props.getI18n().getParameter("connection.connect")));
		//btnConnecter.addActionListener(this);
		c.fill = GridBagConstraints.HORIZONTAL;
		c.gridy = 3;
		c.gridx = 0;
		c.insets = new Insets(50,20,0,0);
		pan.add(btnConnecter, c);
		
		btnAnnuler = new JButton(new CtrlerConnexion(this,Props.getI18n().getParameter("cancel")));
		//btnAnnuler.addActionListener(this);
		c.fill = GridBagConstraints.HORIZONTAL;
		c.gridy = 3;
		c.gridx = 1;
		c.insets = new Insets(50,20,0,0);
		pan.add(btnAnnuler, c);
		
		btnInscrire = new JButton(new CtrlerConnexion(this,Props.getI18n().getParameter("connection.subscribe")));
		//btnInscire.addAbstractAction(this);
		c.fill = GridBagConstraints.HORIZONTAL;
		c.gridy = 3;
		c.gridx = 2;
		c.insets = new Insets(50,20,0,0);
		pan.add(btnInscrire, c);
		
		return pan;
	}
	
	public String getjtLogin(){
		return jtLogin.getText();
	}
	
	public String getjtMdp(){
		return jtMdp.getText();
	}
}
